package cn.ly.recursion.traingle;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import cn.ly.stack.StackX;

public class StackTraingle {
	
	static int theNumber;
	static int theAnswer;
	static StackX theStackX;
	
	public static void main(String[] args) throws IOException {
		System.out.println("Enter a number:");
		theNumber = getInputNum();
		countTraingleByStack();
		System.out.println(theAnswer);
	}
	
	public static void countTraingleByStack(){
		theStackX = new StackX(1000);
		while(theNumber > 0){
			theStackX.push(theNumber);
			theNumber--;
		}
		while(!theStackX.isEmpty()){
			int n = theStackX.pop();
			theAnswer += n;
		}
	}
	
	public static int getInputNum() throws IOException{
		InputStreamReader reader = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(reader);
		return Integer.parseInt(br.readLine());
	}
	
	
	
	

}
